﻿<!--#include file="utf-8.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="seeion.asp"-->
<!--#include file="page.asp"-->
<script language="javascript">
function showUploadDialog(s_Type, s_Link, s_Thumbnail){
var arr = showModalDialog("eWebEditor/dialog/i_upload.htm?style=popup&type="+s_Type+"&link="+s_Link+"&thumbnail="+s_Thumbnail, window, "dialogWidth:0px;dialogHeight:0px;help:no;scroll:no;status:no");}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新闻分类管理</title>
<link href="images/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="head"><strong>添加附件</strong></td>
  </tr>
  <tr>
    <td><form action="Manage_Annex2.asp?type=add" method="post" name="form1" id="form1">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="head_chile">
        <tr>
          <td width="20%" height="25">分类名称</td>
          <td>附件路径</td>
          <td width="10%" align="center">&nbsp;</td>
          <td width="10%" align="center">操作</td>
        </tr>
      </table>
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="20%" height="30"><input name="Title" type="text" class="textbox" id="Title" /></td>
          <td height="30"><input name="Annex" type="text" class="textbox" id="Annex" size="60" />
                <input type="button" class="button_01" onclick="showUploadDialog('file', 'form1.Annex', '')" value="上传附件" /></td>
          <td width="10%" height="30" align="center"><input name="SortID" type="hidden" id="id2" value="2"/></td>
          <td width="10%" height="30" align="center"><input name="submit" type="submit" class="button_01" value="增加附件" /></td>
        </tr>
      </table>
    </form></td>
  </tr>
</table>
<br />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="head"><strong>附件管理</strong></td>
</tr>
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="head_chile">
<tr>
<td width="20%">分类名称</td>
<td>附件路径</td>
<td width="5%" align="center">修改</td>
<td width="5%" align="center">删除</td>
</tr>
</table>
<%	
set rs=server.createobject("adodb.recordset") 
exec="select * from Annex where sortid=2 order by id desc" 
rs.open exec,conn,1,1 
if rs.eof then
response.Write "&nbsp;暂无分类！"
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if	
%>
<%For i=1 To x%>
<form  name="update<%=i%>" method="post" action="Manage_Annex2.asp?type=update">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="20%" height="30"><input name="Title" type="text" class="textbox" id="Title" value="<%=rs("title")%>" /></td>
    <input name="id" type="hidden" id="id" value="<%=rs("id")%>"/>
    <td height="30"><input name="Annex" type="text" class="textbox" id="Annex" value="<%=rs("Annex")%>" size="60"></td>
    <td width="5%" height="30" align="center"><a href="javascript:this.update<%=i%>.submit();">修改</a></td>
    <td width="5%" height="30" align="center"><a href="javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='Manage_Annex2.asp?type=del&id=<%=rs("id")%>';}else{history.go(0);}">删除</a></td>
    </tr>
    </table>
</form>
<%rs.movenext
next
%>
<%end if%>
<br />
<%'以下显示分页
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
rs.close
set rs=nothing
%></td>
</tr>
</table>
</body>
</html>

<% 
if Request.QueryString("type")="update" then
	id=request.Form("id") 
	Title=request.form("Title")
	Annex=request.form("Annex")
	SortID=request.form("SortID")
	sql="select * from Annex where id="&id 
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,3
	if Title=""  then 
		response.Write("<script language=javascript>alert('附件标题不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if Annex=""  then 
		response.Write("<script language=javascript>alert('附件路径不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	rs("Title")=Title
	rs("Annex")=Annex
	rs("SortID")=SortID
	rs.update 
	rs.close 
	response.Write("<script language=""javascript"">alert(""修改分类成功！"");window.location.href='Manage_Annex2.asp';</script>")
end if
%> 

<%
if request("type")="del" then
	set rs=server.createobject("adodb.recordset")
	id=Request.QueryString("id")
	sql="select * from Annex where id="&id
	rs.open sql,conn,2,3
	rs.delete
	rs.update
	Response.Write "<script>alert('附件刪除成功！');window.location.href='Manage_Annex2.asp';</script>" 
end if
%>


<%
if Request.QueryString("type")="add" then
	Title=request.form("Title")
	Annex=request.form("Annex")
	SortID=request.form("SortID")
	set rs=server.createobject("adodb.recordset")
	sql="select Title,Annex,SortID from Annex"
	rs.open sql,conn,1,3
	if Title=""  then 
		response.Write("<script language=javascript>alert('附件标题不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if Annex=""  then 
		response.Write("<script language=javascript>alert('附件路径不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	rs.addnew
	rs("Title")=Title
	rs("Annex")=Annex
	rs("SortID")=SortID
	rs.update
	rs.close
	set rs=nothing
	conn.close
	set rs=nothing
	Response.Write "<script>alert('附件增加成功！');window.location.href='Manage_Annex2.asp';</script>" 
end if
%>